//-------------------------------
// SWDA_Window_SynthesisCommand
//-------------------------------


import { setGlobal } from '@swda/utils'


let SWDAWindowManager = {};
SWDAWindowManager.commandSynthesisCommandButtonImage = 'MenuButton_SynthesisCommand'


class SWDA_Window_SynthesisCommand extends SWDA_Window_Command_4Arrows {
    constructor() {
        super(...arguments)
        this.initialize(...arguments);
    }

    initialize(x, y, width, baseScene){
        super.initialize(x, y);
        this._baseScene = baseScene;
        this.createButtons(SWDAWindowManager.commandSynthesisCommandButtonImage,640,570);
        this.deselect();
        this.deactivate();

        this.refresh();
        this.select(1);
    }

    windowWidth() {
        return 240
    }

    numVisibleRows() {
        return this.maxItems()
    }

    initCommandPosition() {
        this._lastCommandSymbol = null;
    }

    makeCommandList() {
        this.addMainCommands();
    }

    addMainCommands() {
        this.addCommand('', '', false);
        this.addCommand("预览", "result", this.canShowResult());
        this.addCommand('', '', false);
        this.addCommand("重选", "select");
    }


    processOk() {
        SWDA_Window_SynthesisCommand._lastCommandSymbol = this.currentSymbol();
        Window_Command.prototype.processOk.call(this);
    }

    selectLast() {
        if(ConfigManager.commandRemember)
            this.selectSymbol(SWDA_Window_SynthesisCommand._lastCommandSymbol);
    };

    canShowResult() {
        return !!this._baseScene && !!this._baseScene.leftRecipeItem() && !!this._baseScene.rightRecipeItem();
    };
    
}
SWDA_Window_SynthesisCommand._lastCommandSymbol = null;



setGlobal('SWDA_Window_SynthesisCommand', SWDA_Window_SynthesisCommand)